package com.bitejiuyeke.exception;

import com.bitejiuyeke.common.AppResult;
import com.bitejiuyeke.common.ResultCode;

/**
 * @Author 比特就业课
 */

public class ApplicationException extends RuntimeException{

    // 自定义的异常描述
    private AppResult errorResult;

    public ApplicationException(AppResult appResult) {
        // 构造异常中的Message属性
        super(appResult.getMessage());
        // 自定义的错误描述
        this.errorResult = appResult;
    }

    public ApplicationException(String message) {
        super(message);
        // 根据异常描述构建返回对象
        this.errorResult = new AppResult(ResultCode.FAILED.getCode(), message);
    }

    // 指定异常
    public ApplicationException(Throwable cause) {
        super(cause);
    }

    // 自定义异常描述，异常信息
    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }


    public AppResult getErrorResult() {
        return errorResult;
    }

    public void setErrorResult(AppResult errorResult) {
        this.errorResult = errorResult;
    }
}
